package gang.org.springframework.boot.condition;

import gang.org.springframework.framework.annotation.GangConditionContext;
import gang.org.springframework.framework.factory.GangConfigurableListableBeanFactory;
import gang.org.springframework.framework.factory.GangListableBeanFactory;
import gang.org.springframework.framework.metadata.GangAnnotatedTypeMetadata;

import java.util.Set;

/**
 * 业务意义
 *
 * @author chengang
 * @version 1.0
 * @since 2022-04-01 01:30
 */
public class GangOnBeanCondition extends GangFilterSpringBootCondition{

    /**
     * 业务意义
     * 1）GangConditionContext封装类，对BeanFactory, BeanRegister, ClassLoader, ResourceClassLoader的封装
     * */
    @Override
    public Object getMatchOutCome(GangConditionContext context, GangAnnotatedTypeMetadata metadata) {
        //TODO 114行
        getMatchingBeans(context, null);
        return null;
    }

    /**
     * TODO 该业务不做任何处理，只为调起：beanFactory.getBeanNamesForType
     * 业务意义
     * 1）GangConditionContext封装类， 对BeanFactory, BeanRegister, ClassLoader, ResourceClassLoader的封装
     * */
    public final Object getMatchingBeans(GangConditionContext context, Object spec){
        //TODO 169行
        ClassLoader classLoader = context.getClassLoader();
        GangConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        getBeanNamesForType(classLoader, false,beanFactory, null, null);
        return null;
    }

    public Set<String> getBeanNamesForType(ClassLoader classLoader,
                                           boolean considerHierarchy,
                                           GangListableBeanFactory beanFactory,
                                           String type,
                                           Set<Class<?>> parameterizedContainers){
        //TODO 221行
        getBeanNamesForType(beanFactory, false, null, null);
        return null;
    }

    public Set<String> getBeanNamesForType(GangListableBeanFactory beanFactory,
                                           boolean considerHierarchy,
                                           Class<?> type,
                                           Set<Class<?>> parameterizedContainers){
        //TODO 231 行
        collectBeanNamesForType(beanFactory,false,null,null,null);
        return null;
    }

    public Set<String> collectBeanNamesForType(GangListableBeanFactory beanFactory,
                                               boolean considerHierarchy,
                                               Class<?> type,
                                               Set<Class<?>> parameterizedContainers,
                                               Set<String> result){
        //TODO 238 行
        beanFactory.getBeanNamesForType(null, true,false);
        return null;
    }
}
